<template>
  <el-row>
    <el-col :span="24" v-if="orderInfo.modelCode">
      <order-basic :orderDetail="orderDetail"></order-basic>
    </el-col>
    <el-col :span="24" v-if="pickInfo.modelCode || startAddress.modelCode">
      <takeDelivery :orderDetail="orderDetail" @refresh="refresh" :startAddress="startAddress.modelCode"></takeDelivery>
    </el-col>
    <el-col :span="24" v-if="consignee.modelCode || endAddress.modelCode">
      <pickup :orderDetail="orderDetail" :endAddress="endAddress.modelCode"></pickup>
    </el-col>
    <el-col :span="24">
      <goods :orderDetail="orderDetail" v-if="goods.modelCode || serviceInfo.modelCode" :serviceInfo="serviceInfo.modelCode"></goods>
      <order-footer :orderDetail="orderDetail" v-if="goodsOther.modelCode"></order-footer>
    </el-col>
    <el-col :span="24" v-if="verifyInfo.modelCode">
      <write-off :orderDetail="orderDetail"></write-off>
    </el-col>
    <el-col :span="24" v-if="collectionInfo.modelCode">
      <payment-for-goods :orderDetail="orderDetail"></payment-for-goods>
    </el-col>
    <el-col :span="24" v-if="memo.modelCode">
      <memo :orderDetail="orderDetail"></memo>
    </el-col>
  </el-row>
</template>
<script>
import {dotData} from '@/utils'
import orderBasic from '@/views/fhb/myOrders/components/detail/orderBasic'
import takeDelivery from '@/views/fhb/myOrders/components/detail/takeDelivery'
import pickup from '@/views/fhb/myOrders/components/detail/pickup'
import goods from '@/views/fhb/myOrders/components/detail/goods'
import orderFooter from '@/views/fhb/myOrders/components/detail/orderFooter'
import writeOff from '@/views/fhb/myOrders/components/detail/writeOff'
import paymentForGoods from '@/views/fhb/myOrders/components/detail/paymentForGoods'
import memo from '@/views/fhb/myOrders/components/detail/memo'
export default {
  components: {
    orderBasic,
    takeDelivery,
    pickup,
    goods,
    orderFooter,
    writeOff,
    paymentForGoods,
    memo
  },
  props: {
    orderDetail: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  // 订单信息:orderInfo
  // 客户信息:consignee
  // 提货信息:pickInfo
  // 出发地信息:startAddress
  // 目的地信息:endAddress
  // 核销信息:verifyInfo
  // 期望服务时间:predictServiceDate
  // 备注信息:memo
  // 产品信息:goods
  // 服务信息:serviceInfo
  // 费用信息:costInfo
  // 服务商信息:merchantInfo
  // 产品体积信息:goodsOther
  // 代收货款信息:collectionInfo
  computed: {
    fhbOrderCollection() {
      return dotData(this.orderDetail, 'fhbOrderCollection') || {}
    },
    orderInfo() {
      return this.modelShow('orderInfo')
    },
    consignee() {
      return this.modelShow('consignee')
    },
    pickInfo() {
      return this.modelShow('pickInfo')
    },
    startAddress() {
      return this.modelShow('startAddress')
    },
    endAddress() {
      return this.modelShow('endAddress')
    },
    verifyInfo() {
      return this.modelShow('verifyInfo')
    },
    predictServiceDate() {
      return this.modelShow('predictServiceDate')
    },
    memo() {
      return this.modelShow('memo')
    },
    goods() {
      return this.modelShow('goods')
    },
    serviceInfo() {
      return this.modelShow('serviceInfo')
    },
    goodsOther() {
      return this.modelShow('goodsOther')
    },
    collectionInfo() {
      return this.modelShow('collectionInfo')
    }
  },
  methods: {
    modelShow(val) {
      let options = dotData(this.orderDetail, 'options') || []
      let obj = options.find(item => item.modelCode === val)
      if (obj) {
        if (Array.isArray(obj.fieldIsHide)) {
          for (const v of obj.fieldIsHide) {
            obj[v] = v // v存在表示该字段不显示
          }
        }
      } else {
        obj = {}
      }
      return obj
    },
    refresh() {
    }
  }
}
</script>
